<include file="Public:header"/>



<!--添加地址弹窗 end-->

<div class="ShopContain">
    <div class="shopStep">
        <span class="Step01">浏览餐单<b>1</b></span>
        <span class="Step02 aon">确认订餐内容<b>2</b></span>
        <span class="Step03">结算并提交订单<b>3</b></span>
    </div>
    <form name="theform" id="theform" method="post" action="{:U('/Home/Car/setCar')}" enctype="multipart/form-data">
        <div class="address_box">
            <div class="address_consignee">
                <b>送餐地址：</b>
            </div>
            <ul class="addressddList">
                <li class="select_address_list_one aon" addrid="20150926224302979757">
                    <p>
                        <input type="hidden" name="username" value="{$cinfo['truename']}" ><b>{$cinfo['truename']}</b>
                        <input type="hidden" name="phone" value="{$cinfo['phone']}"><b>{$cinfo['phone']}</b>
                        <input type="hidden" name="address" value="{$cinfo['address']}"><b>{$cinfo['address']}</b>
                        <b><a href="{:U('/Home/Ucenter/index')}">修改送餐地址</a></b>
                    </p>
                </li>                    
            </ul>
            <div class="shop_time_tips">送餐时间：成功提交订单后，预计<b>45</b>分钟左右送达</div>
        </div>
        <div class="shopCartbox">
            <div class="CartTop">
                <span class="cart_ico">购物车详情</span>
                <if condition="$isnumber eq iscid "><a href="{:U('/Home/Index/index')}" class="white_btn">返回继续点餐</a><else /> <a href="{:U('/Home/List/index',array($isnumber=>$cid))}" class="white_btn">返回继续点餐</a></if>
                
            </div>
            <div class="Cartcont">
                <table class="cart_table" cellpadding="0" cellspacing="0" width="100%">
                    <tbody>
                        <tr>
                            <th>品名</th>
                            <th>单价（元）</th>
                            <th>数量</th>
                            <th>小计</th>
                            <th class="nobg">取消</th>
                        </tr>
                        <foreach name="tjinfo" item="vo"> 
                       

                            <tr class="cate" id="1632">
                                <td>
                                    <div class="car_img"><img src="{$vo['fpic']}" id="cimageurl1632"></div>
                                    <span class="cart_p_name" id="cproductName1632">{$vo['name']}</span>
                                </td>
                                <td class="ta_center fa_15">￥
                                    <font class="cprice1632">{$vo['price']}</font>
                                    <span class="youhui" style="display:none">{$vo['sprice']}</span>
                                </td>
                                <td class="ta_center">
                                    <span class="num_op">
                                    <b class="jian"></b>                                
                                    <b class="num1632">{$vo['number']}</b>
                                    <b class="jia"></b></span>
                                </td>
                                <td class="ta_center fa_15">￥
                                    <font class="ctrueprice1632"></font>
                                </td>
                                <td class="ta_center">
                                    <span class="cart_remove"></span>
                                    <span class="fid" style="display:none">{$vo['fid']}</span>

            					</td>
                                 <input type="hidden" name="fid[]" value="{$vo['fid']}"> 
                                <input type="hidden" name="price[]" value="{$vo['price']}">
                                <input type="hidden" name="number[]" value="" class="number">
                            </tr>
                        </foreach>                     
                    </tbody>
                 </table>
            </div>
            <div class="Cartbt">
                <div class="w305_input inline" style="padding-top:-100px;">
                    <span>补充说明：</span>
                        <input name="ask" id="orderOthers" placeholder="仅限9个字符" maxlength="9" type="text" style="margin-left:0px;padding-top:-200px;position:absolute;maxlength:20;">
                </div>
            </div>
        </div>
        <div class="InvoiceBox">
            <div class="orderCouponItem">
                <dl class="order-summary">
                    <dt><span>原金额：</span><b id="cartAmount"></b><strong>元</strong></dt>
                    <dd><span>实付总额：</span><b id="cartPamount"></b><strong>元</strong></dd>
                    <dd><span>享受优惠：</span><b id="cartKamount"></b><strong>元</strong></dd>
                </dl>
            </div>
            <div class="payShip">
                <label>货到现金付款</label>
                <span>支付方式：</span>
            </div>
        <!--网上支付 start-->
            
        <!--网上支付 end-->
            <div class="trade-foot">
                <div class="trade_total">
                <input type="hidden" name="fprice" value="">
                    <input id="" value="提交订单" class="red_btn_w116 collection_click" type="submit">
                   <span>实付总额：<b id="cartAmount2"></b>元</span>
                </div>
                <p style="color:pink">温馨提示：点击”提交订单“后，我们的餐厅将会立即开始备餐,备餐时可以取消订单,一旦开始配送您的订单,将不支持取消订单,请提交前仔细核对您的订单内容。</p>
            </div>
        </div>
    </form>
</div>    
        <script type="text/javascript">
       $(function(){
             //删除购物车
           $('.cart_remove').each(function(i){
                
                var t = $(this);
                $(this).click(function(){
                    if(confirm("确定要删除吗？")){
                        
                    }else{
                        return false;
                    }
                    var fid =t.parent().find('.fid').html();
                    // alert(fid);
                    //发送ajax删除car表的foods
                        $.ajax({
                            url:'{:U("Home/Car/cajax")}',
                            data:{'fid':fid},
                            type:'post',
                            async:false,//设置同步
                            success:function(data){
                                //如果用户名不可用
                                if(data==1){
                                    alert('删除成功');
                                    t.parent().prev().find('.ctrueprice1632').html('0');
                                    t.parent().parent().css('display','none').remove();

                                    szj();
                                    // $('body').load('index.html');
                                    // event.stopPropagation();
                                }else{
                                    alert('删除失败');
                                }
                            }
                        });
                   
                })
           });



           
            //改变数量
            $('.jian').click(function(){
               
                    var num1632 = $(this).next().html();
                   if(num1632 < 2 ){
                    alert('不能再小啦');
                    return false;
                   }
                    var num1631 = num1632-1;//减之后的个数
                    $(this).next().html(num1631);
                   //算总价格
                   szj();
               
            });
            //加按钮
            $('.jia').click(function(){
                
                    var num1632 = $(this).prev().html();//每个食物的原个数
                    // alert(num1632);
                    var arr = Number(num1632);
                    // alert(arr);
                    var num1630 = arr+1;//加之后的个数
                    $(this).prev().html(num1630);//修改个数
                   //算总价格
                    szj();
                 
                    
              
             });
            // console.log(arr);
           
           szj();
           //封装的算所有食物的总价的方法
           function szj(){
            //算每个食物的总价格
            var arr = [];//声明总价常量
            var arr1 = [];//声明每个食物的优惠总价
            $('.num1632').each(function(i){
                var num1632 = $(this).html();//获取个数
                var zznum = $('.cprice1632').eq(i).html()*num1632;//算总价
                 // console.log(zznum);
                 //算总优惠
                var youhui = $('.youhui').eq(i).html()*num1632;
                arr1[i] = [youhui]
                arr[i] = [zznum];
                $('.ctrueprice1632').eq(i).html(zznum);
                $('.number').eq(i).val(num1632);//改变提交过去的input食物个数
            });
            // console.log(arr);
            //所有食物的总价格
            var sum = 0;
            for (var i = 0; i < arr.length; i++) {
                var num = Number(arr[i]);
                sum += num;

            };
             var sum1 = 0;//所有优惠的总价
            for (var i = 0; i < arr1.length; i++) {
                var num1 = Number(arr1[i]);
                sum1 += num1;

            };
            $('#cartKamount').html(sum1);
           $('#cartAmount').html(sum);
           var sprice =sum - $('#cartKamount').html();//优惠之后的价格
           // alert(sprice);
           $('#cartPamount').html(sprice);
           $('#cartAmount2').html(sprice);
           $('input[name=fprice]').val(sprice);//改变提交过去的input优惠之后总价
           

           }
           
           //遍历获取购物车修改之后的值
           //购买的个数
           $('.num1632').each(function(i){
                var arr = $(this).html();
                // alert(arr);
           })
           // $('#cartAmount2').html(sum);
          // console.log(sum); 
        


    })


</script>
<include file="Public:footer"/>
     
